package fitnesshub.mapper;

import com.github.pagehelper.Page;
import fitnesshub.pojo.dto.AddCoachDTO;
import fitnesshub.pojo.dto.CoachPageQueryDTO;
import fitnesshub.pojo.entity.Coach;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface CoachMapper {
    /**
     * 教练分页
     * @param coachPageQueryDTO
     * @return
     */
    Page<Coach> pageQuery(CoachPageQueryDTO coachPageQueryDTO);

    /**
     * 根据id查询教练
     * @param coachId
     * @return
     */
    @Select("select * from coach where coach_id = #{coachId}")
    Coach getById(Integer coachId);

    /**
     * 插入一条记录
     * @param coach
     */
    @Insert("insert into coach (coach_name, gender, contact, specialization, introduction, create_time, update_time, avatar, age)" +
            " VALUES " +
            "(#{coachName}, #{gender}, #{contact}, #{specialization}, #{introduction}, #{createTime}, #{updateTime}, #{avatar}, #{age})")
    void insert(Coach coach);

    /**
     * 编辑教练
     * @param coach
     * @return
     */
    void update(Coach coach);

    /**
     * 根据id删除教练
     * @param coachId
     * @return
     */
    @Delete("delete from coach where coach_id = #{coachId}")
    void deleteById(Integer coachId);

}
